# Maintainer: fauxpark <fauxpark@gmail.com>

_realname=libusb-win32
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=1.2.6.0
pkgrel=1
pkgdesc='Port of libusb-0.1 under Windows (mingw-w64)'
arch=('any')
license=('GPL3')
url='https://sourceforge.net/projects/libusb-win32/'
source=(
    "https://downloads.sourceforge.net/project/libusb-win32/libusb-win32-releases/${pkgver}/libusb-win32-src-${pkgver}.zip"
    01-mingw32-ddk-headers.patch
)
sha256sums=(
    'f3faf094c9b3415ede42eeb5032feda2e71945f13f0ca3da58ca10dcb439bfee'
    '71c3f422719cf229e7aaf9e06369ef5a0065b799f2184a4bbd8826bc5fad1687'
)

prepare() {
    cd ${srcdir}/${_realname}-src-${pkgver}

    patch -p1 -i ../01-mingw32-ddk-headers.patch
}

build() {
    cd ${srcdir}/${_realname}-src-${pkgver}

    make dll
}

package() {
    cd ${srcdir}/${_realname}-src-${pkgver}

    install -Dm755 libusb0.dll "${pkgdir}${MINGW_PREFIX}/bin/libusb0.dll"
    install -Dm644 libusb.a "${pkgdir}${MINGW_PREFIX}/lib/libusb0.dll.a"
    install -Dm644 src/lusb0_usb.h "${pkgdir}${MINGW_PREFIX}/include/lusb0_usb.h"
}
